package com.next

class Contact
{
    boolean enabled = true

    /** **************************************************************************************************/

    Date createdDate = new Date()
    Date modifiedDate = new Date()

    String type

    String clientType
    //新老客户

    String fullName
    String cellphone
    String maritalStatus = "未婚"
    Boolean cellphoneHasVerified = false
    String verifiedCode

    String password

    City city

    String idNumber

    String bankName
    String bankAccount

    String avatar

    String userCode
    String openId

    String appSessionId

    ContactLevel level

    Date lastLoginTimestamp = new Date()

    String externalId

    // String company
    // //公司
    // String companyCode
    // //工商&机构代码

    ContactProfession profession
    //职业
    Country country
    //国籍
    ContactIdentityType identityType
    //身份证件类型

    //规则引擎
    Integer queryTimes
    //12个月内央行征信查询次数(贷款审批)
    Integer queryTimesOther
    //12个月内央行征信查询次数(其它查询)
    Integer continuousOverdue
    //贷款连续逾期
    Integer accumulativeOverdue
    //贷款累计逾期
    Boolean currentOverdue = false
    //贷款当前逾期
    String loanState
    //贷款五级分类
    String loanType
    //非正常分类贷款类型
    Double loanAmount
    //非正常分类贷款金额
    String creditCardStatus
    //贷记卡账户状态oldClients
    Double creditCardLimit
    //贷记卡授信额度
    Double guaranteedAmount = 0
    //最大担保金额
    Double currentOverdueAmount = 0
    //当前逾期金额
    String guaranteeState
    //对外担保五级分类

    //风控新界面
    Double income
    //收入
    String propertyOwner
    //是否为抵押人
    String personalProperty
    //个人资产
    String overdueRecentTwoYears
    //2年内逾期次数
    Double totalLoanBalance
    //当前总贷款余额
    String guaranteeStatus
    //对外担保情况
    String guaranteeType
    //对外担保类型
    Double guaranteeBalance
    //对外担保余额(万元)
    String relationOfGuarantor
    //被担保人与借款人关系

    String overdueRecent
    //逾期次数

    static belongsTo = [account: Account, user: User]

    Double monthlyIncome
    //月收入  单位 （元）

    Double monthlyExpenses
    //每月支出  单位（元）

    Double otherInstallmentAmonunt
    //其他存量额度 单位（元）、

    Integer seniority
    //工龄

    Boolean isBlackList = false
    //是否为反欺诈命中客户  默认否

    String creditReportingResults
    //征信结果

    String gender
    //性别
    String nation
    //民族
    Certificate certificate
    //文化程度
    ContactProfessionTitle professionTile
    //专业职称
    String job
    //职务
    Boolean accumulationFund
    //是否有公积金
    Boolean socialSecurity
    //是否有社保
    Integer age
    //年龄
    Boolean isCorporation
    //是否为企业法人

    Integer currentSeniority
    //现单位工作年限
    String companyName
    //单位名称
    String companyAddress
    //单位地址
    Industry industry
    //行业
    String residentialAddress
    //居住地址
    Boolean houseOwner
    //是否有房产
    String jobLevel
    //职位等级
    String socialInsuranceAccount
    //社保账号
    String socialInsuranceVerifyMethod
    //社保核验方式
    Double socialInsuranceBaseAmount
    //社保缴存基数
    String socialInsuranceUnit
    //社保缴存单位
    Date socialInsuranceStartTime
    //社保缴存起始日期
    Double socialInsurancePersonalAmount
    //社保个人缴存金额
    Double socialInsuranceUnitAmount
    //社保单位缴存金额
    String housingFundAccount
    //公积金账号
    Double housingFundBalance
    // 公积金余额
    String housingFundVerifyMethod
    // 公积金核验方式
    Double housingFundBaseAmount
    // 公积金缴存基数
    String housingFundUnit
    // 公积金缴存单位
    Date housingFundStartTime
    // 公积金缴存起始日期
    Double housingFundPersonalAmount
    // 公积金个缴存金额
    Double housingFundPersonalRatio
    // 公积金个人缴存比例
    Double housingFundUnitAmount
    // 公积金单位缴存金额
    Double housingFundUnitRatio
    // 公积金单位缴存比例

    SeniorityRange seniorityRange
    //工作年限区间
    String individualIncomeTaxVerifyMethod
    // 个税核验方式
    Date individualIncomeTaxStartTime
    // 个税缴存起始日期
    Double individualIncomeTaxPersonalAmount
    // 个税个人缴存额
    Double individualIncomeTaxPersonalRatio
    // 个税个人缴比例
    Date birthday
    // 身份证上的出生日期
    String nativePlace
    // 身份证上的住址
    String authority
    // 身份证签发机关
    String periodOfValidity
    // 身份证有效期限
    String householdRegistrationType
    // 客户户籍
    Certificate highestCertificate
    // 最高学位
    String fairsType
    // FAIRS分类
    HouseOrigin houseOrigin
    // 现住房来源及居住状况
    String residentialDuration
    // 现住址居住时间
    String companyZipCode
    // 工作单位邮编
    String companyPhone
    // 工作单位电话
    Integer companyMemberCount
    // 单位人数
    String phone
    // 联系人电话
    String bankDealings
    // 银行往来情况
    String beCustomerDuration
    // 成为中行客户时间
    String monthlyIncomeType
    // 月收入类型
    String monthlyIncomeVerifyMethod
    // 月收入验证方式
    Double otherMembersMonthlyIncome
    // 家庭其他成员月收入
    String otherMembersMonthlyIncomeVerifyMethod
    // 家庭其他成员月收入验证方式
    HouseType houseType
    // 现有住房种类
    String cardCountRange
    // 持卡情况
    Integer familyMembersCount
    // 家庭成员数量
    Integer fendCount
    // 供养人口数
    Boolean individualIncomeTax
    // 是否有个税
    Date workTime
    // 参加工作时间
    Double socialInsurancePersonalRatio
    // 社保个人缴存比例
    Double socialInsuranceUnitRatio
    // 社保公司缴存比例
    AccountEconomyType companyEconomyType
    // 工作单位经济类型
    String maritalVerifyMethod
    // 婚姻状况核验方式
    String drivingLicenseVerifyMethod
    // 驾照核验方式
    String monthlyIncomeVerifyMethodMemo
    // 月收入验证方式 其他
    String othersIncomeVerifyMemo
    // 家庭其他成员月收入验证方式 其他
    ContactJob contactJob
    //联系人职务
    Date currentWorkTime
    // 现工作入职时间

    Boolean isHighQualityIndustry
    //是否为优质行业
    Integer numberOfHouse
    //房产数量
    Double totalPriceOfHouse
    //房产总价值
    String address
    //常住地址
    String zipCode
    //常住地址邮编
    Province province
    // 常住地址省份
    District district
    // 常住地址区域
    Boolean isProvideBusinessLicense
    // 是否提供任职单位营业执照
    Boolean isProvideResidentCertificate
    // 是否提供居留证明
    String contactSourceOfConsumerLoan
    // 消贷客户来源
    String contactMarkupOfConsumerLoan
    // 消贷关联客户标记
    String contactCharacter
    // 客户特征
    ContactFeatureCategory contactFeatureCategory
    // 客户特征标签1
    ContactFeature contactFeature
    // 客户特征标签2
    String surnameOfMother
    // 母亲姓氏

    Boolean isResident = true
    // 是否是居民
    String language = "中文"
    // 通讯语言
    String email
    //邮箱

    Province nativeProvince
    // 身份证上的省
    City nativeCity
    // 身份证上的市
    District nativeDistrict
    // 身份证上的区
    String nativePlaceDetail
    // 身份证上的详细地址
    Province companyProvince
    // 工作单位所在省
    City companyCity
    // 工作单位所在市
    District companyDistrict
    // 工作单位所在区

    String firstName
    //名
    String lastName
    //姓
    String firstNameSpell
    //名拼音
    String lastNameSpell
    //姓拼音
    Double monthlyTotalIncome
    //每月家庭总收入

    // static hasMany = [messages: Message, certificates: ContactLoginCertificate, loginHistory: ContactLoginHistory]
    //static hasMany = [certificates: ContactLoginCertificate, attachments: Attachments]
    static hasMany = [certificates: ContactLoginCertificate, companies: Company, contactJudgementRecord: ContactJudgementRecord]

    static mapping = {
        type column: '`type`'
        job column: '`job`'
        password column: '`password`'
        socialInsuranceVerifyMethod column: '`social_insurance_v_method`'
        socialInsurancePersonalAmount column: '`social_insurance_p_amount`'
        individualIncomeTaxVerifyMethod column: '`individual_tax_v_method`'
        individualIncomeTaxStartTime column: '`individual_tax_start_time`'
        individualIncomeTaxPersonalAmount column: '`individual_tax_p_amount`'
        individualIncomeTaxPersonalRatio column: '`individual_tax_p_ratio`'
        otherMembersMonthlyIncomeVerifyMethod column: '`others_monthlyincome_v_method`'
        socialInsurancePersonalRatio column: '`social_insurance_p_ratio`'
        monthlyIncomeVerifyMethodMemo column: '`monthly_income_v_method_memo`'
        isProvideResidentCertificate column: '`is_provide_r_certificate`'
        contactSourceOfConsumerLoan column: '`contact_source_of_c_loan`'
        contactMarkupOfConsumerLoan column: '`contact_markup_of_c_loan`'
    }

    static constraints = {
        fullName blank: true, nullable: true, maxSize: 32
        cellphone blank: true, nullable: true
        cellphone matches: /^1\d{10}$/
        city blank: true, nullable: true, maxSize: 16
        maritalStatus inList: ["未婚", "已婚", "初婚", "再婚", "复婚", "丧偶", "离婚", "其他"]
        maritalStatus maxSize: 8
        type blank: true, nullable: true
        type inList: ["Agent", "Client"]
        clientType blank: true, nullable: true
        clientType maxSize: 16, inList: ['new', 'old']
        account blank: true, nullable: true
        idNumber blank: true, nullable: true, size: 15..18
        verifiedCode blank: true, nullable: true, maxSize: 6
        user blank: true, nullable: true
        password blank: true, nullable: true, maxSize: 32
        bankName blank: true, nullable: true, maxSize: 32
        bankAccount blank: true, nullable: true, maxSize: 21
        avatar blank: true, nullable: true, maxSize: 32
        userCode blank: true, nullable: true, maxSize: 32
        openId blank: true, nullable: true, maxSize: 64
        level blank: true, nullable: true
        appSessionId blank: true, nullable: true, size: 0..256

        externalId maxSize: 32, blank: true, nullable: true //, unique: true
        //        company maxSize: 128, nullable: true, blank: true
        //        companyCode maxSize: 128, nullable: true, blank: true

        // industry nullable: true, blank: true
        profession nullable: true, blank: true
        country nullable: true, blank: true
        identityType nullable: true, blank: true
        //规则引擎
        queryTimes nullable: true, blank: true
        queryTimesOther nullable: true, blank: true
        continuousOverdue nullable: true, blank: true
        accumulativeOverdue nullable: true, blank: true
        loanState inList: ["正常", "关注", "次级", "可疑", "损失"]
        loanState nullable: true, blank: true, maxSize: 8
        loanType inList: ["房产抵押", "信用", "其它"]
        loanType nullable: true, blank: true, maxSize: 20
        loanAmount nullable: true, blank: true
        creditCardStatus inList: ["正常", "止付", "冻结", "呆账", "黑户"]
        creditCardStatus nullable: true, blank: true, maxSize: 8
        creditCardLimit nullable: true, blank: true
        guaranteedAmount nullable: true, blank: true
        currentOverdue nullable: true, blank: true
        guaranteeState inList: ["正常", "关注", "次级", "可疑", "损失"]
        guaranteeState nullable: true, blank: true, maxSize: 8
        currentOverdueAmount nullable: true, blank: true

        //风控新界面
        income nullable: true, blank: true
        propertyOwner inList: ["是", "否"], nullable: true, blank: true, maxSize: 4
        personalProperty maxSize: 1024, nullable: true, blank: true
        overdueRecentTwoYears maxSize: 16, nullable: true, blank: true
        totalLoanBalance nullable: true, blank: true
        guaranteeStatus inList: ["有", "无"], nullable: true, blank: true, maxSize: 8
        guaranteeType inList: ["信用卡担保", "贷款担保"], nullable: true, blank: true, maxSize: 10
        guaranteeBalance nullable: true, blank: true
        relationOfGuarantor nullable: true, blank: true, maxSize: 16

        overdueRecent maxSize: 16, nullable: true, blank: true
        monthlyIncome blank: true, nullable: true
        monthlyExpenses blank: true, nullable: true
        otherInstallmentAmonunt blank: true, nullable: true
        seniority blank: true, nullable: true
        isBlackList blank: true, nullable: true
        creditReportingResults blank: true, nullable: true
        creditReportingResults inList: ["A", "B", "BBB"], maxSize: 8

        gender inList: ['男', '女'], nullable: true, blank: true, maxSize: 4
        nation blank: true, nullable: true, maxSize: 32
        certificate blank: true, nullable: true
        professionTile blank: true, nullable: true
        job maxSize: 32, nullable: true, blank: true

        accumulationFund blank: true, nullable: true
        socialSecurity blank: true, nullable: true
        age blank: true, nullable: true
        isCorporation blank: true, nullable: true

        currentSeniority blank: true, nullable: true
        companyName blank: true, nullable: true, maxSize: 32
        companyAddress blank: true, nullable: true, maxSize: 128
        industry blank: true, nullable: true
        residentialAddress blank: true, nullable: true, maxSize: 128
        houseOwner blank: true, nullable: true
        jobLevel blank: true, nullable: true
        socialInsuranceAccount blank: true, nullable: true
        socialInsuranceVerifyMethod blank: true, nullable: true, maxSize: 32
        socialInsuranceBaseAmount blank: true, nullable: true
        socialInsuranceUnit blank: true, nullable: true, maxSize: 32
        socialInsuranceStartTime blank: true, nullable: true
        socialInsurancePersonalAmount blank: true, nullable: true
        socialInsuranceUnitAmount blank: true, nullable: true
        housingFundAccount blank: true, nullable: true
        housingFundBalance blank: true, nullable: true
        housingFundVerifyMethod blank: true, nullable: true, maxSize: 32
        housingFundBaseAmount blank: true, nullable: true
        housingFundUnit blank: true, nullable: true, maxSize: 32
        housingFundStartTime blank: true, nullable: true
        housingFundPersonalAmount blank: true, nullable: true
        housingFundPersonalRatio blank: true, nullable: true
        housingFundUnitAmount blank: true, nullable: true
        housingFundUnitRatio blank: true, nullable: true

        seniorityRange blank: true, nullable: true
        individualIncomeTaxVerifyMethod blank: true, nullable: true, maxSize: 32
        individualIncomeTaxStartTime blank: true, nullable: true
        individualIncomeTaxPersonalAmount blank: true, nullable: true
        individualIncomeTaxPersonalRatio blank: true, nullable: true
        birthday blank: true, nullable: true
        nativePlace blank: true, nullable: true, maxSize: 128
        authority blank: true, nullable: true, maxSize: 32
        periodOfValidity blank: true, nullable: true, maxSize: 32
        householdRegistrationType blank: true, nullable: true, maxSize: 32, inList: ["港澳台", "外省", "本省", "本地"]
        highestCertificate blank: true, nullable: true
        fairsType blank: true, nullable: true, maxSize: 32, inList: ["美国人", "非美国人", "暂未做FAIRS分类", "其他"]
        houseOrigin blank: true, nullable: true
        residentialDuration blank: true, nullable: true, maxSize: 32
        companyZipCode blank: true, nullable: true, maxSize: 6
        companyPhone blank: true, nullable: true, maxSize: 11
        companyMemberCount blank: true, nullable: true
        phone blank: true, nullable: true, maxSize: 11
        bankDealings blank: true, nullable: true, maxSize: 32, inList: ["工资卡和定期存款", "仅有工资卡", "仅有定期存款", "未知"]
        beCustomerDuration blank: true, nullable: true, maxSize: 32, inList: ["未知", "5年或以上", "3-4年", "1-2年", "1年以下", "新客户"]
        monthlyIncomeType blank: true, nullable: true, maxSize: 32, inList: ["工资", "投资", "其他"]
        monthlyIncomeVerifyMethod blank: true, nullable: true, maxSize: 32
        otherMembersMonthlyIncome blank: true, nullable: true
        otherMembersMonthlyIncomeVerifyMethod blank: true, nullable: true, maxSize: 32
        houseType blank: true, nullable: true
        cardCountRange blank: true, nullable: true, maxSize: 32, inList: ["未知", "0张", "1张", "2-3张", "4张以上"]
        familyMembersCount blank: true, nullable: true
        fendCount blank: true, nullable: true
        individualIncomeTax blank: true, nullable: true
        workTime blank: true, nullable: true
        socialInsurancePersonalRatio blank: true, nullable: true
        socialInsuranceUnitRatio blank: true, nullable: true
        companyEconomyType blank: true, nullable: true
        maritalVerifyMethod blank: true, nullable: true, maxSize: 32, inList: ["系统自动验证", "人工验证"]
        drivingLicenseVerifyMethod blank: true, nullable: true, maxSize: 32, inList: ["系统自动验证", "人工验证"]
        monthlyIncomeVerifyMethodMemo blank: true, nullable: true, maxSize: 32
        othersIncomeVerifyMemo blank: true, nullable: true, maxSize: 32
        contactJob blank: true, nullable: true
        currentWorkTime blank: true, nullable: true

        isHighQualityIndustry blank: true, nullable: true
        numberOfHouse blank: true, nullable: true
        totalPriceOfHouse blank: true, nullable: true
        address blank: true, nullable: true, maxSize: 128
        zipCode blank: true, nullable: true, maxSize: 6
        province blank: true, nullable: true
        district blank: true, nullable: true
        isProvideBusinessLicense blank: true, nullable: true
        contactSourceOfConsumerLoan blank: true, nullable: true, maxSize: 128, inList: ["本行员工", "VIP客户", "理财客户", "分行推荐客户", "其他"]
        contactMarkupOfConsumerLoan blank: true, nullable: true, maxSize: 128, inList: ["开发商/经销商员工", "建筑企业员工", "开发商/经销商关联企业员工", "其他关联客户", "非关联人"]
        contactCharacter blank: true, nullable: true, maxSize: 128, inList: ["政府各级领导", "中行授信单位中层以上领导", "员工或员工担保", "存款大户", "理财客户", "其他"]
        contactFeatureCategory blank: true, nullable: true
        contactFeature blank: true, nullable: true
        isProvideResidentCertificate blank: true, nullable: true
        surnameOfMother blank: true, nullable: true, maxSize: 32

        language blank: true, nullable: true, maxSize: 32, inList: ["中文", "英文"]
        isResident blank: true, nullable: true
        email nullable: true, blank: true, email: true
        nativeProvince nullable: true, blank: true
        nativeCity nullable: true, blank: true
        nativeDistrict nullable: true, blank: true
        nativePlaceDetail nullable: true, blank: true, maxSize: 128
        companyProvince nullable: true, blank: true
        companyCity nullable: true, blank: true
        companyDistrict nullable: true, blank: true

        firstName nullable: true, blank: true, maxSize: 32
        lastName nullable: true, blank: true, maxSize: 32
        firstNameSpell nullable: true, blank: true, maxSize: 64
        lastNameSpell nullable: true, blank: true, maxSize: 64
        monthlyTotalIncome nullable: true, blank: true
    }

    def beforeInsert()
    {
        if (userCode)
        {
            user = User.findByCode(userCode)
        }
    }

    def beforeUpdate()
    {
        if (userCode)
        {
            user = User.findByCode(userCode)
        }
        modifiedDate = new Date()
    }
}
